package program.conditions;

import item.*;

/**
 * A class for dealing with at-item-conditions: (at-item).  
 * 
 */
public class AtItem extends Conditions {

        /**
         * Initialise this new at-item-condition with a line number.
         *
         */
        public AtItem(int lineNb) {
                super(lineNb);
        }

        /**
         * Evaluates this condition for a given robot.
         * 
         * @return      
         * 			| for one element in robot.getPosition.getBoard().getItemsAtPosition(robot.getPosition()):
         *          |       if(item instanceof Item) 
         *          |               then result == super.evaluate(robot)
         *          |       else then result == false
         */
        @Override
        public boolean evaluate(Robot robot) {
        	for (Item item: robot.getPosition().getListOfItemsAtPosition())
        		if(item instanceof Item) return super.evaluate(robot);
                return false;
        }

        /**
         * Return a textual representation of this at-item-condition,
         * formatted in accordance with its position in the program.
         * 
         * @return      The result is a pretty formatted string of this at-item-condition,
         *                      taking in account his relative position in the program.
         *                      | result == getIndentation(indentationLevel) + "(at-item)"
         */
        @Override
        public String prettyFormat(int indentationLevel) {
                return getIndentation(indentationLevel) + "(at-item)";
        }

}